class DateUtil {
  // 格式化时间
  static String format(DateTime date, String format) {
    int year = date.year;
    format = format.replaceAll('yyyy', year.toString().padLeft(4, '0'));
    format = format.replaceAll('yy', (year % 100).toString().padLeft(2, '0'));
    format = format.replaceAll('mm', date.month.toString().padLeft(2, '0'));
    format = format.replaceAll('dd', date.day.toString().padLeft(2, '0'));
    format = format.replaceAll('hh24', date.hour.toString().padLeft(2, '0'));
    format = format.replaceAll('mi', date.minute.toString().padLeft(2, '0'));
    format = format.replaceAll('ss', date.second.toString().padLeft(2, '0'));
    format =
        format.replaceAll('ms', date.millisecond.toString().padLeft(3, '0'));
    return format;
  }
}
